Repository navigation
M6/J873g: enable Kopsia hardware video decoding - #2139
Conversation
c18032f to
a544621
Compare
|
Rebased onto integration/aurora 0abc2f3. It is now a544621 (was b782c27); the old branch no longer merged.
On 0abc2f3: Image, modules and the J873g DTB build (LLVM 22, the M6's config, W=1, no warnings in the touched files), |
|
Thanks, Thomas. Bit-exact results for five codecs, with a check that rules out software fallback, are a strong start for the M6 decoder. A few code asks, so this keeps working as more T8152 machines are added:
Row: boot the exact PR head on the J873g and repeat your comparison for H.264, HEVC, HEVC Main10, VP9 and AV1, 60 frames each, all exact. Then run 4K60 H.264 to a null sink at 60 fps or more. With power-off added, After that we will run a no-regression row for the shared DART changes on our A18 Pro (Neo) and M4 Pro. |
a544621 to
ee96cb6
Compare
|
Thanks. I've done the parts I can verify without the M6. The head is now
Still open, and both need the M6:
I haven't booted this head yet. When the M6 is back on its tether, I'll run the row you listed: the five codecs × 60 frames compared exactly, 4K60 H.264 to a null sink, and the genpd summary once power-off exists. |
ee96cb6 to
4919818
Compare
|
Small follow-up: I rewrapped one overlong line in the DART commit message (checkpatch), so the head is now |
|
J873g decode row. The exact head can't boot the J873g from its SSD by itself: integration has no J873g NVMe, which comes with #1797. So the kernel is #2178's head
The genpd row (AVD off after 10 s idle, on for the next decode) waits for the power-off path, which is what I'm doing next. It comes with the generic PSD provider discussed on #1797. |
|
Thanks, Thomas. The SoC description, the dropped address check and the comment on the ADT mailbox pair cover those points. The decode row on #2178 is fine given the NVMe dependency. Still open before this leaves draft: the PSD power-off, and Gen3 DART fault reporting ( On the 346 decoder tunables: the table is avd-fw's v5/tier2 one, made for an earlier decoder. Does the J873g ADT Row once power-off lands: |
4919818 to
892664b
Compare
|
The power-off path is in. The head is now
genpd row on the J873g (#2178's stack, which carries these commits):
That leaves the Gen3 DART fault handler, which I'm working on now on the M6. |
892664b to
b4923f3
Compare
|
Gen3 faults are done. The head is now Gen3 DART faults ("iommu: apple-dart: report T8152 Gen3 DART faults"). A Gen3 DART turns out to report faults like a v2 DART: the pending-stream bitmap at 0x4000 and a record per stream at 0x8000 (status, address), acknowledged by writing the bitmap back. So Gen3 DARTs now request their interrupt and use Tested on the J873g with a TEST-only knob that cleared the AVD DART's SID 0 TTBR during an H.264 decode:
The commit is the one I added at the end of #1800, carried here after this PR's copies of #1800's DART commits. I also updated the backend commit's message, because PostOffice completion and suspend/resume are now the only open parts. With the power-off path and this, all of the code asks from your review are addressed. |
b4923f3 to
e9da854
Compare
|
On the decoder tunables: the J873g ADT's I don't have a trace of macOS's register writes on the M6. The macOS tracer I have runs on the J813 only, and an M6 MMIO trace of the decoder bring-up is a separate project. What I can show comes from outside, on the J873g. With this table:
That's what the backend commit ( |
|
Thanks, Thomas. The power-off path with the genpd numbers, and the Gen3 fault handler with the injected-fault test, cover everything we asked for in the code. The lock-on-error case stopping the stream rather than touching the query register is the right call. On the tunables: thanks for checking the ADT and for putting the evidence in the commit. Whether the table needs an M6 trace as well is a question for the maintainer review, so no need to start that project for us. For leaving draft: once #2459 and #1800 are in, a rebase that drops their copies here (the PSD binding and driver, and the DART commits) would leave this PR with only its own decoder changes. |
e9da854 to
6a2bbe8
Compare
|
Rebased onto integration/aurora Assisted-by: LLM (Claude:Opus 5.5) |
|
Re-review of 6a2bbe8: no change to the decoder or DART code. The only changes are the host-test fixture fields for the new Assisted-by: LLM (Claude:Opus 5.5) |
|
@RyanTheTide the J873g rerun on this head ( Kernel:
The five codecs. 60 frames each, with
Assisted-by: LLM (Claude:Opus 5.5) |
6a2bbe8 to
834a46b
Compare
|
Rebased onto integration/aurora 95a13cf. The head is 834a46b. One conflict:
Commits 1-9, 11 and 12 are identical; 10 differs only by this resolution. Checks:
Assisted-by: LLM (Claude:Opus 5.5) |
|
Thanks for the J873g rerun at 6a2bbe8: five codecs with 0 differing frames and the concurrent three-process run cover the rebase. 834a46b is a rebase only. Commit 10 differs only by keeping #2773's Assisted-by: LLM (Claude:Opus 5.5) |
|
I retested
FFmpeg logged the I also checked probe failures on the host using the actual probe code with simulated hardware responses. An unsupported Kopsia ID returned The runtime power measurement above supersedes the always-on limitation in the opening description. Whole-machine suspend/resume and decoder recovery after a hardware fault were outside this run. |
|
@Acelogic thanks for the row and both fixes. I reviewed them and they are right:
One thing before merge: neither f7450a2 nor 7df685e has a I also updated the description. Your runtime-PM measurement replaces the "power domain stays on" note, since PSD power-off has been in the series since the 11-19 rework. Your row is listed, and the base line now names your integration merge. Assisted-by: LLM (Claude:Opus 5.5) |
The AVD Gen3 DART uses the shared TLBI aperture like the display DARTs, but Linux initializes it from an unlocked state with inactive streams. Require its PSD power domain, DMA aperture and initialization tunables. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Admit cold Gen3 setup only for the instance its apple,t8152-avd-dart compatible selects, with version 0x300, 16 streams, its PSD domain, ADT tunables and inactive streams 0..2. Clear those streams, apply their tunables and use the Gen3 TLBI aperture before enabling translation. Map the TLBI aperture before reset and select a two-level 16K page table inside a single 64 GiB high DMA window. Keep the existing locked display DART admission and all other unlocked Gen3 instances unchanged. On J873g this maps all three decoder streams for bit-exact H.264, HEVC, HEVC Main10, VP9 and AV1 decoding. Gen3 fault IRQ handling and suspend recovery remain outside this initial bring-up. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Describe the Kopsia MCU, decoder, wrapper and PIODMA register apertures, its three DART streams and its shared PSD power domain. The initial transport submits from the host with the MCU halted and polls completion; it does not use the PostOffice mailbox or the legacy decoder reset line. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
T8152 Kopsia retains the T8142 codec program format but uses different initialization and completion registers. Add a host backend that halts the MCU, initializes the wrapper and PIODMA, and reuses the existing codec submission and completion logic with one frame in flight. Poll VP/PP status only while a frame is active. Enable H.264, HEVC, VP9 and AV1 on this variant without an external firmware image. Retain the 128-byte H.264 MV and HEVC v5 header quirks. Disable recovery reset: the existing watchdog parks DMA and retires the decoder instead of issuing an unqualified reset. The 346 register tunables are unchanged from the MIT-licensed avd-fw v5/tier2 table. The J873g ADT's avd node carries no tunables of its own (unlike its DART's), so there is nothing T8152-specific to describe in the device tree. The table was checked on the J873g by its output: with it, H.264, HEVC, HEVC Main10, VP9 and AV1 decode bit-exact against software (60 frames each), 4K60 H.264 runs at about 150 fps, and the results stay exact across hundreds of power-domain cycles, each of which applies the table again. On J873g, forced DRM PRIME decode and download compares exactly with software for 60 frames of each codec, including HEVC Main10; mpv also renders through DRM PRIME and seeks in both directions. The decoder is runtime power-gated through its PSD domain: the backend is set up again on every resume. A DART fault (injected on the J873g) retires the decoder through the existing recovery path until the module is reloaded. PostOffice completion and suspend/resume remain outstanding. Link: https://github.com/aurora-silicon/avd-fw/blob/ea3a65cc9c0c41907e6ad2714b813e4be6858485/src/hw/tunables/tunables_v5t2.h Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Describe the T8152 Kopsia decoder in the SoC peripherals, disabled, so every T8152 board can enable it: its five register banks, PSD service 50 (apple,t8152-psd) as the power domain shared by the decoder and its DART, powered off by genpd while both are idle, and the DART as the apple,t8152-avd-dart instance with its Gen3 TLBI aperture, its initialization tunables and a 64 GiB window at 1 TiB inside the native 1..4 TiB DMA aperture. The tunables are those of the J873g's ADT. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Enable the T8152 decoder, its PSD domain and its DART on the J873g. This enables the request decoder node used by FFmpeg and mpv on the M6 Mac mini. The PSD provider supplies both AVD and DART so translation is initialized only after their shared domain is powered. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The Kopsia backend checks the hardware ID at the first runtime resume. Propagate a failed resume before registering the media device. Preserve the existing firmware transport probe behavior.
Allocate the empty IOMMU domain after the fallible backend, DMA and power-domain setup. Cancel the queue work scheduled on runtime resume and release the empty domain when probe fails after enabling runtime PM.
7df685e to
e75d185
Compare
|
I rebased the original PR onto the public #1800 merge The M6 booted this exact head through public aura with the display and decoder drivers enabled and all 12 CPUs online. FFmpeg selected the hardware AVD driver in every stream.
On the same boot the combined stack also passed the 3840×2160 KMS modeset, 60 page flips, and disable/re-enable check, using the measured main-DCP endpoint handoff documented on #1800. Local checks on this source tree passed again (12/12 AVD, 16/16 DART and 3/3 PMGR). Both changed bindings and the rebuilt J873g DTB also passed scoped validation using dtschema 2026.9. The six controlled probe cases are documented in the earlier test comment. |
This enables V4L2 Request hardware decoding on the Mac mini M6 (J873g/T8152). With the request-enabled FFmpeg/mpv packages, H.264, HEVC/Main10, VP9 and AV1 decode through Kopsia, and mpv presents DRM PRIME frames without a download to the CPU.
Draft for review of the initial hardware bring-up: completion is polled. The decoder and its PSD power domain are runtime power-managed: off at idle, on while frames are in flight. System suspend and fault recovery are not qualified.
Scope and prerequisites
Originally based on
integration/auroraat0abc2f385e54. Acelogic has since mergedintegration/auroraup to5701541b5cd5into the branch (ce48dd2), and added two probe-error fixes (f7450a2, 7df685e). The first three commits carry the Gen3 DART binding, locked-stream support and VHE TLBI fix from #1800, with their source commits recorded. The remaining seven commits add:The 346 decoder tunables match the MIT-licensed avd-fw v5/tier2 table, with its attribution retained. #2106 is a related Gen3 DART implementation to reconcile during review. There are no new aura, FFmpeg or mpv source changes in this series.
Hardware validation
Mac mini M6,
apple,j873g/apple,t8152, Debian forky/sid. Tested kernel:7.3.0-aurora-j873-avd+(#6), built from the local M6 integration base805d9fcc6812plus this decoder implementation. The exact rebased PR branch has not been booted; its build/schema/host checks are listed separately below.Both
asahi,os-fw-versionandasahi,system-fw-versionreportunknown; the installed aura Stage 1 version was not recorded. Userspace: FFmpeg7:9.0.2-6+v4l2req2, mpv/libmpv20.42.0-1+v4l2req2, Mesa26.3.0~aurora.wip.ac9d556248c-1, Sway1.12-1, OpenGL renderer Apple M6 (G18G B1).Repeated after the final reboot:
The tests force
-hwaccel v4l2request -hwaccel_output_format drm_prime, download to NV12/P010, normalize to the software pixel format and compare nonempty frame hashes. Logs must also identify the AVD media driver, so software fallback cannot pass. Three simultaneous H.264/HEVC/VP9 processes also produced 60 exact frames each.Additional hardware results:
hwdec=v4l2requestand DRM PRIME interop, with zero decoder or presentation drops during that test./dev/video10and/dev/media0present; no AVD errors, kernel WARNING/Oops/SError, or failed systemd units in the final boot.Select
hwdec=v4l2requestin mpv. FFmpeg needs-hwaccel v4l2requestbefore the input; use-hwaccel_output_format drm_primewhen retaining hardware frames. CPU filters need an explicit download.Acelogic's M6 row at 7df685e (booted from RAM through public aura, 12 CPUs, lockdep on):
Checks on this PR branch
W=1: complete AVD objects, PSD and DART objects, and the J873g DTB build. Existing DART unused-helper and GPU reserved-memory DT warnings remain.dt_binding_check; the J873g DTB passes validation against those schemas.git diff --checkpasses. Checkpatch reports no errors; remaining warnings concern new-file MAINTAINERS coverage and British spelling of acknowledgment.Remaining work
PostOffice completion is not implemented: completion is polled. Gen3 fault interrupts remain disabled, and recovery reset is disabled for Kopsia: the existing watchdog parks DMA and retires the decoder rather than issuing an unqualified reset. Whole-machine suspend/resume and fault injection have not been tested. Encoding and browser integration are outside this change.
Assisted-by: LLM (Claude:Opus 5.5)